package cn.yh.action;

import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;

public class BaseAction {
	/**
	 * 解耦的session
	 * @return
	 */
	public Map<String,Object> getMapSession(){
		return ActionContext.getContext().getSession();
	}
	/**
	 * 解耦的request
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Map<String,Object> getMapRequest(){
		return (Map<String,Object>)ActionContext.getContext().get("request");
	}
	/**
	 * 耦合的request
	 * @return
	 */
	public HttpServletRequest getRequest(){
		HttpServletRequest request = ServletActionContext.getRequest();
		return request;
	}
	/**
	 * 耦合的response
	 * @return
	 */
	public HttpServletResponse getResponse(){
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/html;charset=utf-8");
		return response;
	}
	
	public HttpSession getSession(){
		return ServletActionContext.getRequest().getSession();
	}
	
}
